home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Digitalfoto 118
/
Digitalfoto 118.iso
/
mac
/
programas
/
00
/
start.swf
/
scripts
/
FFPSControllerSymbol.as
next >
Wrap
Text File
|
2009-11-16
|
5KB
|
201 lines
FPSController = function()
{
this.setFPSTarget(this._targetInstanceName);
this.initPause();
this.init();
this.initProps();
};
FPSController.prototype.init = function()
{
this.sT = getTimer();
this.tF = this._tget._totalframes;
this.isStop = false;
if(this.playMode == "Forward")
{
this._tget.gotoAndStop(1);
}
else if(this.playMode == "Reverse")
{
this._tget.gotoAndStop(this.tF);
}
else if(this.playMode == "PingPong")
{
this.initPingPong();
}
else if(this.playMode == "Random")
{
this.FgotoToRandom();
}
};
FPSController.prototype.initPingPong = function()
{
this.initialDirection = this.initialDirection != undefined ? this.initialDirection : "Forward";
this.playDirection = this.initialDirection.substring(0,1).toLowerCase();
if(this.playDirection == "f")
{
this._tget.gotoAndStop(1);
}
else if(this.playDirection == "r")
{
this._tget.gotoAndStop(this.tF);
}
else
{
this.tget.gotoAndStop(1);
this.playDirection = "f";
}
};
FPSController.prototype.setFPSTarget = function(tget)
{
if(typeof tget == "string")
{
this._tget = this._parent[tget];
}
else if(typeof tget == "movieclip")
{
this._tget = tget;
}
this.tF = this._tget._totalframes;
this.attachMethods();
};
FPSController.prototype.getFPSTarget = function()
{
return this._tget;
};
FPSController.prototype.setFPS = function(fps)
{
this.fps = fps;
this.initPause();
};
FPSController.prototype.getFPS = function()
{
return this.fps;
};
FPSController.prototype.initPause = function()
{
this.pauseFor = Math.floor(1000 / this.fps);
};
FPSController.prototype.setPlayMode = function(playMode, initialDirection)
{
this.playMode = playMode;
this.initialDirection = initialDirection;
if(playMode == "PingPong")
{
this.initPingPong();
}
};
FPSController.prototype.getPlayMode = function()
{
return this.playMode;
};
FPSController.prototype.FgotoAndStop = function(fnum)
{
this.gotoAndStop(fnum);
this._tget.isStop = true;
};
FPSController.prototype.FgotoAndPlay = function(fnum)
{
this.gotoAndStop(fnum);
this._tget.isStop = false;
};
FPSController.prototype.Fstop = function()
{
this.stop();
this._tget.isStop = true;
};
FPSController.prototype.Fplay = function()
{
this._tget.isStop = false;
};
FPSController.prototype.FnextFrame = function()
{
if(this._tget.cF == this._tget.tF && this._tget.playMode == "Forward")
{
this.gotoAndStop(1);
}
else if(this._tget.cF == this._tget.tF && this._tget.playMode == "PingPong")
{
this.prevFrame();
this._tget.playDirection = "r";
}
else
{
this.nextFrame();
}
};
FPSController.prototype.FprevFrame = function()
{
if(this._tget.cF == 1 && this._tget.playMode == "Reverse")
{
this.gotoAndStop(this._tget.tF);
}
else if(this._tget.cF == 1 && this._tget.playMode == "PingPong")
{
this.nextFrame();
this._tget.playDirection = "f";
}
else
{
this.prevFrame();
}
};
FPSController.prototype.FgotoToRandom = function()
{
var _loc2_ = 1 + Math.floor(Math.random() * (this._tget.tF - 1));
this.gotoAndStop(_loc2_);
};
FPSController.prototype.onEnterFrame = function()
{
if(!this.isStop)
{
this.tS = getTimer() - this.sT;
this.cF = this._tget._currentframe;
if(this.tS >= this.pauseFor)
{
if(this.playMode == "Forward")
{
this._tget.FnextFrame();
}
else if(this.playMode == "Reverse")
{
this._tget.FprevFrame();
}
else if(this.playMode == "PingPong")
{
if(this.playDirection == "f")
{
this._tget.FnextFrame();
}
else if(this.playDirection == "r")
{
this._tget.FprevFrame();
}
}
else if(this.playMode == "Random")
{
this._tget.FgotoToRandom();
}
this.sT = getTimer();
}
}
};
FPSController.prototype.attachMethods = function()
{
this._tget._tget = this;
this._tget.FgotoAndStop = this.FgotoAndStop;
this._tget.FgotoAndPlay = this.FgotoAndPlay;
this._tget.Fstop = this.Fstop;
this._tget.Fplay = this.Fplay;
this._tget.FnextFrame = this.FnextFrame;
this._tget.FprevFrame = this.FprevFrame;
this._tget.FgotoToRandom = this.FgotoToRandom;
ASSetPropFlags(this._tget,["_tget","FgotoAndStop","FgotoAndPlay","Fstop","Fplay","FnextFrame","FprevFrame","FgotoToRandom"],1);
};
FPSController.prototype.initProps = function()
{
this.addProperty("fps",this.getFPS,this.setFPS);
this.addProperty("_tget",this.getFPSTarget,this.setFPSTarget);
this.addProperty("playMode",this.getPlayMode,this.setPlayMode);
};
Object.registerClass("FFPSControllerSymbol",FPSController);